package View;

import javax.imageio.ImageIO;

import javax.swing.JPanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagLayout;


import javax.swing.JButton;
import javax.swing.border.EmptyBorder;
import javax.swing.border.MatteBorder;

import Presenter.LoadMenuPresenter;


import java.awt.GridBagConstraints;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.awt.Insets;
import java.io.File;
import java.io.IOException;
import javax.swing.UIManager;

@SuppressWarnings("serial")
public class  LoadMenuView extends JPanel{
	
	/**
	 * 
	 */
	private final JPanel contentPane, panel;
	
	public LoadMenuView() {
		contentPane = this;
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

		panel = this;
		panel.setBorder(new MatteBorder(1, 1, 1, 1, new Color(0, 0, 0)));
		panel.setPreferredSize(new Dimension(500, 360));
		
		final GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 53};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 
		        Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
		        Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		final JButton btnNewButton = new JButton("New Game");
		btnNewButton.setBackground(UIManager.getColor("Button.background"));
		btnNewButton.setForeground(new Color(255, 0, 0));
		
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new LoadMenuPresenter().newButton();
			}
		});
		
		final GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
		gbc_btnNewButton.gridx = 1;
		gbc_btnNewButton.gridy = 7;
		add(btnNewButton, gbc_btnNewButton);
		
		final JButton btnLoadGame = new JButton("Load Game");
		btnLoadGame.setForeground(new Color(255, 0, 0));
		final GridBagConstraints gbc_btnLoadGame = new GridBagConstraints();
		gbc_btnLoadGame.gridx = 4;
		gbc_btnLoadGame.gridy = 7;
		add(btnLoadGame, gbc_btnLoadGame);
		
		btnLoadGame.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new LoadMenuPresenter().loadButton();
			}
		});
		
		
	}

	public void paintComponent (Graphics g){
		super.paintComponent(g);
		BufferedImage image = null;
		try{
			image = ImageIO.read(new File("src\\View\\title page.jpg"));
			
		}
		catch(IOException e){
			System.out.println(e.getMessage());
			}
		
		g.drawImage(image, 0, 0, null);
		
	}



}
